<%--
 *  File:    AttchmentNew.jsp
 *  @Author: Kolleryao
 *  Date:    2002/11/28
 *
 *  Copyright (C) 2000 - 2002 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>
<%@ page import="com.oval.util.OvalLabel" %>
<%@ page import="com.oval.util.OvalCustomColumn" %>
<%@ page import="com.oval.util.OvalCustomMessage" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>


<% //--------------------------------------  setting logger --%>
<%
  	Category cat = Category.getInstance("jsp.AddressEdit");
%>

<% //--------------------------------------  variant and initialization --%>
<%
  	String strModuleName = "BIEE";
  	String strTableName = "ovaddresssummaryforcrm";
    String strOrgid=(String)request.getParameter("orgid");

    HashMap userInfo = (HashMap)session.getAttribute("userinfo");
//    System.out.println("userinfo = " + userInfo);
	if (strOrgid==null || "".equals(strOrgid))
	{

        Integer Intorgid=(Integer)session.getAttribute("orgid");
	    strOrgid=String.valueOf(Intorgid);
//        System.out.println("if nei strOrgid  = " + strOrgid);
        if(strOrgid==null || "".equals(strOrgid))
        {
//              System.out.println("(Integer)userInfo.get(\"orgid\") = " + (Integer)userInfo.get("orgid"));
              strOrgid=String.valueOf((Integer)userInfo.get("orgid"));
//              System.out.println("(Integer)userInfo.strOrgid = " + strOrgid);
        }
	}

//    System.out.println("session.getAttribute(\"orgid\") = " + session.getAttribute("orgid"));
//    System.out.println("request.getParameter(\"orgid\") = " + request.getParameter("orgid"));
//    System.out.println("strOrgid = " + strOrgid);

    String  forumid = request.getParameter("forumid");
//    System.out.println("forumid(requst) = " + forumid);
    if(forumid == null || "".equals(forumid))
    {
       forumid = String.valueOf(session.getAttribute("forumid"));
       //forumid = (String)session.getAttribute("forumid");
//         System.out.println("forumid(session) = " + forumid);
    }
	//Integer Integerorgid= Integer.valueOf(strOrgid);


	Integer Maker=(Integer)userInfo.get("userid");
	Integer curorgid=(Integer)userInfo.get("orgid");
	String filename=(String)session.getAttribute("filename");
	String filesize=(String)session.getAttribute("filesize");
	String filetype=(String)session.getAttribute("filetype");
	String uploadfilepath=(String)session.getAttribute("uploadfilepath");
	String attachmentname=(String)session.getAttribute("attachmentname");

	if (filename!=null)
	session.removeAttribute("filename");
	if (filesize!=null)
	session.removeAttribute("filesize");
	if (filetype!=null)
	session.removeAttribute("filetype");
	if (attachmentname!=null)
	session.removeAttribute("attachmentname");

	//session.setAttribute("orgid",Integerorgid);
%>


<% //--------------------------------------  include files list --%>

<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>

<html>
<head>
<title><%= label.getLabelName("L_NEAccessory") %> </title>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%


%>
<link rel="stylesheet" href="../css/<%=strLanguageCode%>/main.css" type="text/css">
<script language="JavaScript" src="../css/<%=strLanguageCode%>/script.js">
</script>
</head>
<script>
function uploadfile()
{
	var file=cform.file.value;

	if(cform.file.value=="")
    return;

  if (file.indexOf("\\")!=-1)
    file = file.substring(file.lastIndexOf("\\")+1,file.length);

	cform.filename.value = file;
  <%--[SCRIPT] alert("filename="+cform.filename.value);   [SCRIPT]--%>
  cform.filetype.value=file.substring(file.lastIndexOf(".")+1,file.length);
  <%--[SCRIPT]  alert("filetype="+cform.filetype.value);  [SCRIPT]--%>
  <%--[SCRIPT]  alert("file="+cform.file.value);  [SCRIPT]--%>
	cform.actionname.value = "upload";
  	cform.target = "_self";
  	isRunning = true;
  	cform.submit();
}

function saveit()
{
	if(cform.filename.value=="")
	{alert("<%= message.getMessageDesc("P_UPLOAD_FIRST ")%>");
	return;
	}
	if(cform.attachmentname.value=="")
	{       alert("<%= message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_AccessoryName",false)) %>");

	return;
	}

cform.actionname.value = "save";
  	cform.target = "_self";
  	isRunning = true;
  	cform.submit();
 }
</script>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><img src="../images/<%=strLanguageCode%>/quote.gif" width="16" height="11"> <%=label.getLabelName("L_NEAccessory") %>
    </td>
  </tr>
</table>
<table border="1" cellspacing="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" align="center" width="100%" cellpadding="1">

<form name="cform" method="post" action="../Dispatcher"  target="_self" ENCTYPE="multipart/form-data">
	<input type="hidden" name="filename" value="<%=JspHelper.filterNull(filename)%>">
	<input type="hidden" name="filetype" value="<%=JspHelper.filterNull(filetype)%>">
	<input type="hidden" name="actionname">
	<input type="hidden" name="pagename" value="attchmentnew">
    <input type="hidden" name="relatedentityid" value="<%=JspHelper.filterNull(forumid)%>">
	<input type="hidden" name="relatedentitytype" value="1">
    <input type="hidden" name="orgid" value="<%=JspHelper.filterNull(curorgid)%>">
	<input type="hidden" name="maker" value="<%=JspHelper.filterNull(Maker)%>">
     <input type="hidden" name="forumid" value="<%=JspHelper.filterNull(forumid)%>">
<input type="hidden" name="uploadpath" value="<%=JspHelper.filterNull(uploadfilepath)%>">
  <tr>
    <td class="need" width="100"><%=label.getLabelName("L_AccessoryName") + label.getLabelName("L_Colon")%></td>
    <td colspan="3">
		<custom:text property="attachmentname" value="<%=attachmentname%>"/>
    </td>
  </tr>
  <tr>
    <td class="need" width="100"><%=label.getLabelName("L_SelectFile")%>:</td>
    <td colspan="3">
      <input type="file" name="file" size="68" value="<%=JspHelper.filterNull(filename)%>">
      <a onclick="uploadfile()"><custom:button type="1" label="L_Upload" imgsrc="Upload.gif" border="0" style="width:60"/></a> </td>
  </tr>
  <tr>
  <td class="td-text" width="100"><%=label.getLabelName("L_filename")%>:</td>
    <td colspan="3">&nbsp;<custom:write property="filename" value="<%=filename%>"/></td>
  </tr>
  <tr>
    <td class="td-text" width="100"><%=label.getLabelName("L_FileSize") + label.getLabelName("L_Colon") %></td>
    <td width="317">&nbsp;<custom:write property="filesize" value="<%=filesize%>"/>KB</td>
    <input type="hidden" name="filesize" value="<%=JspHelper.filterNull(filesize)%>">
	<td class="td-text" width="124"><%=label.getLabelName("L_filetype") + label.getLabelName("L_Colon") %></td>
    <td width="460">&nbsp;<custom:write property="filetype" value="<%=filetype%>"/></td>
  </tr>
  <tr>
    <td class="td-text" width="100"><%=label.getLabelName("L_Comments") + label.getLabelName("L_Colon") %></td>
    <td colspan="3">
		<custom:text property="comments"/>
    </td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td class="summary_top"></td>
  </tr>
  <tr>
    <td class="td_center"><a onclick="saveit()"><custom:button type="1" label="L_Save" imgsrc="save.gif" border="0" style="width:60"/></a> <a onclick="self.location.href='Blank.jsp?<%= OvalTools.randomURL() %>';"><custom:button type="1" label="L_Cancel" imgsrc="cancel.gif" border="0" style="width:60"/></a></td>
  </tr>
</table>
</body>
</html>


